/****** Object:  Stored Procedure [dbo].spChiTietBienBanNhapHangSelectAllByMaBBNH Script Date: 7/16/2012 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[spChiTietBienBanNhapHangSelectAllByMaBBNH]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].[spChiTietBienBanNhapHangSelectAllByMaBBNH]
GO

/******************************************************************************
**		Change History
*******************************************************************************
**		Date:		Author:					Description:
**		--------	--------				-----------------------------------
**		17/07/2012	SongTM					Innit created
*******************************************************************************/

CREATE PROCEDURE [dbo].[spChiTietBienBanNhapHangSelectAllByMaBBNH]
(
	@MaBBNH nvarchar(12)
)
WITH ENCRYPTION

AS

SET NOCOUNT ON

SELECT 
	[tbl_ChiTietBienBanNhapHang].*,
	[tbl_ChiTietPhieuNhap].MaCTPN,
	[tbl_ChiTietPhieuNhap].SoPN,
	[tbl_ChiTietPhieuNhap].SoLuong,
	[tbl_ChiTietPhieuNhap].DonGia,
	tbl_LuuKho.*
FROM 
	[tbl_ChiTietBienBanNhapHang] INNER JOIN tbl_ChiTietPhieuNhap on tbl_ChiTietPhieuNhap.MaCTPN = tbl_ChiTietBienBanNhapHang.MaCTPN
	INNER JOIN tbl_LuuKho ON tbl_LuuKho.MaLuuKho=tbl_ChiTietPhieuNhap.MaLuuKho
WHERE [MaBBNH] = @MaBBNH
GO

--GRANT EXECUTE ON [dbo].[spChiTietBienBanNhapHangSelectAllByMaBBNH] TO [sa]
--GO
